package top.aiprogram.common.utils;

import javax.xml.crypto.Data;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by HP on 2018/10/17.
 */
public class DateUtils {

    private static Calendar calendar=Calendar.getInstance();

    /*
    @Author JackQi {www.coder520.com}
    @DATE 2018/10/17 12:43
    @Description:获取今天是周几
    */
    public static int getWeek(){
        calendar.setTime(new Date());
        int i = calendar.get(Calendar.DAY_OF_WEEK)-1;
        if (i<=0){
            i=7;
        }
        return i;
    }
    /*
    @Author JackQi {www.coder520.com}
    @DATE 2018/10/17 12:46
    @Description:获取今天的上班时长
    */
    public static long getMinute(Date startday,Date endday){
        long time = startday.getTime();
        long time1 = endday.getTime();
        long abs = Math.abs(time - time1);
        long l = abs / (1000 * 60);
        return l;
    }
    /*
    @Author JackQi {www.coder520.com}
    @DATE 2018/10/17 12:52
    @Description:获取当天的某个时间,主要用于获取做判断对比的时间
    */
    public static Date getDate(int hour,int minute){
        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,minute);
        Date time = calendar.getTime();
        return time;
    }
}
